<?php
    require('db_connection.php');
    $query = "SELECT * FROM tblcirculation WHERE status LIKE 'reserved'";
    $result = mysql_query($query);
?>
<!doctype html public "-//W3C//DTD HTML 4.01//EN">

<html>
   <head>
      <title>Circulation</title>
      <meta http-equiv="generator" content="PHP Designer 2005" />
      <style type="text/css">
        @import url(style.css);
      </style>
   </head>

   <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000" class=''>


    <table width='80%' align='center' class='content'>
        <tr><td colspan='2'><img src='images/banner.jpg' /></td></tr>
            <tr><td align='right' colspan='2' class='logout'><?php require ('loginout.php');?></td></tr>
        <tr><td>
            <table align='left' width='40%' class='bodyborder'>
                <tr class='tools'><td><a href='bookborrowed.php'>Books Borrowed</a> | <a href='bookreserved.php'>Books Reserved</a></td>
                </tr>
            </table>
            <table align='right' width='45%' class='bodyborder'>
            <?php
                    $userType = $_COOKIE['userType'];

                    if($userType=='superadministrator')
                    {
                        echo "<tr class='tools'><td align='right'><a href='circulation.php'>Circulation</a> | Reserve | Borrow | <a href='mainsad.php'>Home</a></td>";

                    }
                    else
                    {
                        echo "<tr class='tools'><td align='right'><a href='circulation.php'>Circulation</a> | Reserve | Borrow | <a href='main.php'>Home</a></td>";
                    }
                ?>
                </tr>
            </table>
            </td>
        </tr>
        <tr><td>
            <table align='center' cellspacing='0' cellpadding='3'>
            <tr><td height='30'></td></tr>
            <tr class='listtable'><th></th><th>Library Card No</th><th>Accession No.</th><th>Call No.</th><th>Title</th><th>Author</th><th>Publisher</th></tr>

            <?php
            $libraryNo = $_COOKIE['libraryNo'];
            $ctr=1;
                while ($row = mysql_fetch_array($result))
                {
                    //echo "<tr><td></td></tr>";
                    $materialID = $row['materialID'];
                    $libraryNotmp = $row['libraryNo'];
                    $userID = $row['userID'];
                    if($libraryNo==$libraryNotmp)
                    {
                        $query2 = "SELECT * FROM tblcollection WHERE materialID LIKE '$materialID'";
                        $result2 = mysql_query($query2);
                            while ($row = mysql_fetch_array($result2))
                            {
                                $callNo = $row['callNo'];
                                $title = $row['title'];
                                $author = $row['author'];
                                $publisher = $row['publisher'];
                                $materialID = $row['materialID'];
                                $accessionNo = $row['accessionNo'];
                            }
                        $query1 = "SELECT * FROM tblclient WHERE userID = '$userID'";
                        $result1 = mysql_query($query1);
                            while ($row = mysql_fetch_array($result1))
                            {
                                $libraryCardNo = $row['libraryCardNo'];
                                $libraryNo = $row['libraryNo'];
                            }

                    }
                            

                    //echo "<form method='post' action=''>";
                    echo"<tr align='center'><td  class='listborder'>$ctr.</td><td class='listborder'><a href='transactions.php?libraryCardNo=$libraryCardNo&libraryNo=$libraryNo'>$libraryCardNo</a></td><td  class='listborder'>$accessionNo</td><td  class='listborder'>$callNo</td><td  class='listborder'>$title</td><td  class='listborder'>$author</td><td  class='listborder'>$publisher</td></tr>";
                    //echo"</tr>";
                    //echo "</form>";
                    $ctr++;
                }
            ?>
            <tr><td height='30'></td></tr>
            </table>
            </td>
        </tr>
        <tr><td align='center' colspan='2'><?php require ('copyright.php')?></td></tr>
    </table>


   </body>
</html>
